﻿using System;
using System.Collections.Generic;
using System.Text;

namespace ICarPool.ORM.Common
{
    public class TypeUtils
    {
        public static object ConvertForType(object value,Type type)
        {
            switch (type.FullName)
            {
                case "System.String":
                    value = value.ToString();
                    break;

                case "System.Boolean":
                    value = bool.Parse(value.ToString());
                    break;

                case "System.Int16":
                     value = int.Parse(value.ToString());
                    break;
                case "System.Int32":
                     value = int.Parse(value.ToString());
                    break;
                case "System.Int64":
                    value = Int64.Parse(value.ToString());
                    break;

                case "System.Double":
                    value = double.Parse(value.ToString());
                    break;

                case "System.Decimal":
                    value = new decimal(double.Parse(value.ToString()));
                    break;
                    
                case "System.Single":
                    value = float.Parse(value.ToString());
                    break;

                case "System.DateTime":
                    value = DateTime.Parse(value.ToString());
                    break;

                case "System.Byte[]":
                    value = (System.Byte[])value;
                    break;
                    
                    
            }
            return value;
        }
    }
}
